home *** CD-ROM | disk | FTP | other *** search
/ Sony Community Place / BROWSER / APP / CHAT / CHATROOM.EXE / program files / Sony / Community Place Browser / world / chatroom / scripts / touch.java < prev    next >
Encoding:
Java Source  |  1996-12-12  |  3.0 KB  |  116 lines

  1. /*
  2.  * Copyright(C) 1996 Sony Corporation. All rights reserved.
  3.  */
  4.  
  5. import vrml.*;
  6. import vrml.field.*;
  7. import vrml.node.*;
  8. import java.util.*;
  9. import vs.*;
  10.  
  11. public class touch extends Script{
  12.     /* Node */
  13.     //SFNode        TouchNode;
  14.  
  15.     /* EventOut */
  16.     SFVec3f        TouchViewpointPosition;
  17.     SFTime        Floor2ndAudioClipStartTime;
  18.     SFTime        Floor2ndAudioClipStopTime;
  19.     SFColor        Floor2ndMaterialColor;
  20.  
  21.     float ViewPos[] = new float[3];
  22.  
  23.     static int R = 0;
  24.     static int G = 1;
  25.     static int B = 2;
  26.  
  27.     static int X = 0;
  28.     static int Y = 1;
  29.     static int Z = 2;
  30.     static int DEGREE = 3;
  31.  
  32.  
  33.     public void initialize() {
  34.         /* Node */
  35.         //TouchNode                = (SFNode) getField( "TouchNode" );
  36.  
  37.         /* EventOut */
  38.         TouchViewpointPosition            = (SFVec3f)    getEventOut( "TouchViewpointPosition" );
  39.         Floor2ndAudioClipStartTime        = (SFTime)    getEventOut( "Floor2ndAudioClipStartTime" );
  40.         Floor2ndAudioClipStopTime        = (SFTime)    getEventOut( "Floor2ndAudioClipStopTime" );
  41.         Floor2ndMaterialColor            = (SFColor)    getEventOut( "Floor2ndMaterialColor" );
  42.     }
  43.  
  44.     public void processEvent(Event e) {
  45.         String name = e.getName () ;
  46.  
  47.         if(name.equals("TouchProximitySensorPosition_changed"))    {TouchProximitySensorPosition_changed(e);}
  48.         if(name.equals("TouchBoxTouchSensorIsActive"))            {TouchBoxTouchSensorIsActive(e);}
  49.         if(name.equals("TouchConeTouchSensorIsActive"))            {TouchConeTouchSensorIsActive(e);}
  50.         if(name.equals("Floor2ndProximitySensorIsActive"))        {Floor2ndProximitySensorIsActive(e);}
  51.     }
  52.  
  53.     public void TouchProximitySensorPosition_changed(Event e) {
  54.         ConstSFVec3f pos = (ConstSFVec3f)e.getValue();
  55.  
  56.         ViewPos[X] = pos.getX();
  57.         ViewPos[Y] = pos.getY();
  58.         ViewPos[Z] = pos.getZ();
  59.     }
  60.  
  61.     public void TouchTouchSensorIsActive(Event e) {
  62.         ConstSFBool mouse_down = (ConstSFBool)e.getValue();
  63.         double time = e.getTimeStamp();
  64.     
  65.         if (mouse_down.getValue()) return;    /* mouseDown */
  66.         
  67.         //TouchStart( time );
  68.     }
  69.  
  70.     public void TouchBoxTouchSensorIsActive(Event e) {
  71.         ConstSFBool mouse_down = (ConstSFBool)e.getValue();
  72.         float pos[] = new float[3];
  73.     
  74.         if (mouse_down.getValue()) return;    /* mouseDown */
  75.     
  76.         pos = ViewPos;
  77.         pos[Z] += 5.0f;
  78.         TouchViewpointPosition.setValue(pos);
  79.     }
  80.  
  81.     public void TouchConeTouchSensorIsActive(Event e) {
  82.         ConstSFBool mouse_down = (ConstSFBool)e.getValue();
  83.         float pos[] = new float[3];
  84.     
  85.         if (mouse_down.getValue()) return;    /* mouseDown */
  86.     
  87.         pos = ViewPos;
  88.         pos[Y] += 5.0f;
  89.         TouchViewpointPosition.setValue(pos);
  90.     }
  91.  
  92.     public void Floor2ndProximitySensorIsActive(Event e) {
  93.         ConstSFBool proximity = (ConstSFBool)e.getValue();
  94.         double time = e.getTimeStamp();
  95.         float col[] = new float[3];
  96.     
  97.         if (proximity.getValue()) {
  98.             Floor2ndAudioClipStartTime.setValue(time);
  99.             Floor2ndAudioClipStopTime.setValue(-1);
  100.             col[R] = 255.0f;
  101.             col[G] = 0.0f;
  102.             col[B] = 0.0f;
  103.         }{
  104.             Floor2ndAudioClipStopTime.setValue(time);
  105.             col[R] = 0.0f;
  106.             col[G] = 255.0f;
  107.             col[B] = 0.0f;
  108.         }
  109.         Floor2ndMaterialColor.setValue(col);
  110.     
  111.     }
  112.  
  113.  
  114. }
  115. 
  116.